package com.hualude.roadsign.repository;

import com.hualude.roadsign.model.UserPushTimeEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

public interface UserPushTimeRepository extends CrudRepository<UserPushTimeEntity, Integer> {

    @Modifying
    @Query(value="update UserPushTimeEntity set roadSignTime=?2 where userId=?1")
    public Integer updateRoadSignTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set signalLampTime=?2 where userId=?1")
    public Integer updateSignalLampTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set signalMachineTime=?2 where userId=?1")
    public Integer updateSignalMachineTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set solarEnergyTime=?2 where userId=?1")
    public Integer updateSolarEnergyTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set highLeverTime=?2 where userId=?1")
    public Integer updateHighLeverTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set roadLineTime=?2 where userId=?1")
    public Integer updateRoadLineTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set guardrailTime=?2 where userId=?1")
    public Integer updateGuardrailTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set monitorTime=?2 where userId=?1")
    public Integer updateMonitorTime(Integer userId, String nowTime) throws Exception;

    @Modifying
    @Query(value="update UserPushTimeEntity set coverTime=?2 where userId=?1")
    public Integer updateCoverTime(Integer userId, String nowTime) throws Exception;

    @Query(value = "from UserPushTimeEntity where userId=?1")
    public  UserPushTimeEntity getPushTimeByUserId(Integer userId);
}
